Skip to content

test(angular-query-experimental): replace hardcoded query keys with 'queryKey()' utility#10418

Merged
sukvvon merged 1 commit intomainfrom
test/angular-query-replace-hardcoded-keys-with-queryKey
Apr 7, 2026
Merged

test(angular-query-experimental): replace hardcoded query keys with 'queryKey()' utility#10418
sukvvon merged 1 commit intomainfrom
test/angular-query-replace-hardcoded-keys-with-queryKey

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 7, 2026

🎯 Changes

  • Replace hardcoded query/mutation keys with queryKey() utility from @tanstack/query-test-utils across angular-query-experimental test files
  • Applied to runtime tests (.test.ts) and type tests (.test-d.ts)
  • Files modified: inject-query.test.ts, inject-query.test-d.ts, inject-mutation.test.ts, inject-mutation-state.test.ts, inject-infinite-query.test.ts, inject-infinite-query.test-d.ts, inject-is-fetching.test.ts, inject-is-mutating.test.ts, inject-queries.test-d.ts, query-options.test-d.ts, infinite-query-options.test.ts, infinite-query-options.test-d.ts, mutation-options.test.ts, mutation-options.test-d.ts, pending-tasks.test.ts

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Enhanced test suite infrastructure by standardizing query and mutation key generation patterns across Angular Query experimental test cases.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Updates test files in the angular-query-experimental package to replace hard-coded query and mutation key literals with dynamically generated keys using the queryKey() helper from @tanstack/query-test-utils. This affects 14 test files with consistent pattern application across infinite queries, query injection, query options, mutations, and query state scenarios.

Changes

Cohort / File(s) Summary
Infinite Query Tests
infinite-query-options.test-d.ts, infinite-query-options.test.ts, inject-infinite-query.test-d.ts, inject-infinite-query.test.ts
Replaces hard-coded ['key'] and ['example'] literals with const key = queryKey() in infinite query options and injection scenarios. Updates type assertions and QueryClient data access calls to use generated keys.
Query Options & Injection Tests
query-options.test-d.ts, inject-queries.test-d.ts, inject-query.test-d.ts, inject-query.test.ts
Replaces static query key arrays with queryKey()-generated values across multiple test cases. Updates both type-testing assertions and runtime test logic to use generated keys for signal initialization and query-dependent scenarios.
Mutation Tests
mutation-options.test-d.ts, mutation-options.test.ts, inject-mutation.test.ts, inject-mutation-state.test.ts
Converts hard-coded mutationKey literals (e.g., ['key'], ['mutation']) to dynamically generated keys via queryKey(). Adjusts mutation cache lookups and reactive mutation key tests to reference generated key instances.
Query State Tests
inject-is-fetching.test.ts, inject-is-mutating.test.ts
Updates query/mutation key registration from static array literals to queryKey()-generated values while preserving test control flow and timing assertions.
Task Management
pending-tasks.test.ts
Converts fixed array literals (e.g., ['cancel-test']) to generated keys, ensuring QueryClient.cancelQueries and query-targeting operations reference the same dynamically created key instances.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 The keys were hard, now they dance free,
Generated helpers from the utility tree,
Patterns aligned across the test terrain,
No more static strings to maintain!
Hopping forward with dynamic grace, ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: replacing hardcoded query keys with a queryKey() utility in angular-query-experimental test files.
Description check ✅ Passed The PR description follows the template structure, providing clear details about changes, affected files, and appropriately marking the change as dev-only with no release impact.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/angular-query-replace-hardcoded-keys-with-queryKey

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 7, 2026

View your CI Pipeline Execution ↗ for commit a586d79

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 46s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-07 04:34:33 UTC

@sukvvon sukvvon self-assigned this Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 7, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10418

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10418

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10418

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10418

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10418

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10418

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10418

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10418

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10418

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10418

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10418

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10418

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10418

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10418

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10418

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10418

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10418

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10418

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10418

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10418

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10418

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10418

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10418

commit: a586d79

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

size-limit report 📦

Path Size
react full 11.98 KB (0%)
react minimal 9.01 KB (0%)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/angular-query-experimental/src/__tests__/inject-mutation.test.ts (1)

600-640: Minor: Unnecessary blank line at line 601.

There's an extra blank line after the key declaration that creates inconsistency with other test patterns in this file.

Suggested fix
       const key = queryKey()
-
       const mutation1 = TestBed.runInInjectionContext(() =>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/angular-query-experimental/src/__tests__/inject-mutation.test.ts`
around lines 600 - 640, Remove the unnecessary blank line after the const key =
queryKey() declaration in the inject-mutation.test.ts snippet so it matches the
file's test formatting; this affects the block that creates mutation1 and
mutation2 via TestBed.runInInjectionContext(() => injectMutation(...))—keep the
key declaration immediately followed by the mutation1 creation to maintain
consistency with other tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/angular-query-experimental/src/__tests__/inject-mutation.test.ts`:
- Around line 600-640: Remove the unnecessary blank line after the const key =
queryKey() declaration in the inject-mutation.test.ts snippet so it matches the
file's test formatting; this affects the block that creates mutation1 and
mutation2 via TestBed.runInInjectionContext(() => injectMutation(...))—keep the
key declaration immediately followed by the mutation1 creation to maintain
consistency with other tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 787c35dc-457d-4d23-8b07-da12efc14a61

📥 Commits

Reviewing files that changed from the base of the PR and between dbe3f95 and a586d79.

📒 Files selected for processing (15)
  • packages/angular-query-experimental/src/__tests__/infinite-query-options.test-d.ts
  • packages/angular-query-experimental/src/__tests__/infinite-query-options.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-infinite-query.test-d.ts
  • packages/angular-query-experimental/src/__tests__/inject-infinite-query.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-is-fetching.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-is-mutating.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-mutation-state.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-mutation.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-queries.test-d.ts
  • packages/angular-query-experimental/src/__tests__/inject-query.test-d.ts
  • packages/angular-query-experimental/src/__tests__/inject-query.test.ts
  • packages/angular-query-experimental/src/__tests__/mutation-options.test-d.ts
  • packages/angular-query-experimental/src/__tests__/mutation-options.test.ts
  • packages/angular-query-experimental/src/__tests__/pending-tasks.test.ts
  • packages/angular-query-experimental/src/__tests__/query-options.test-d.ts

@sukvvon sukvvon merged commit 4335fce into main Apr 7, 2026
10 checks passed
@sukvvon sukvvon deleted the test/angular-query-replace-hardcoded-keys-with-queryKey branch April 7, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant